package com.ttg.web.config;

import com.ttg.web.filter.AuthFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;

import javax.servlet.Filter;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/7/5 17:24
 */
@Configuration
public class FilterConfig {

    @Bean
    public Filter filterAuth() {
        return new AuthFilter();
    }


    @Bean
    public FilterRegistrationBean filterAuthRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new DelegatingFilterProxy("filterAuth"));
        registrationBean.addUrlPatterns("/*");
        registrationBean.setName("filterAuth");
        // 优先级
        registrationBean.setOrder(1);
        return registrationBean;
    }
}
